package work.coffee.dto;

public class Coffee implements Comparable<Coffee>{
	private String cNum;
	private String cName;
	private int cPrice;
	private int cCount;
	private int cMargin;
	public Coffee() {
	}
	public Coffee(String cNum, String cName, int cPrice, int cCount, int cMargin) {
		this.cNum = cNum;
		this.cName = cName;
		this.cPrice = cPrice;
		this.cCount = cCount;
		this.cMargin = cMargin;
	}
	public Coffee(String cNum, int cPrice, int cCount, int margin) {
		this.cNum = cNum;
		this.cPrice = cPrice;
		this.cCount = cCount;
		this.cMargin = margin;
	}
	public String getcNum() {
		return cNum;
	}
	public void setcNum(String cNum) {
		this.cNum = cNum;
	}
	public String getcName() {
		return cName;
	}
	public void setcName(String cName) {
		this.cName = cName;
	}
	public int getcPrice() {
		return cPrice;
	}
	public void setcPrice(int cPrice) {
		this.cPrice = cPrice;
	}
	public int getcCount() {
		return cCount;
	}

	public void setcCount(int cCount) {
		this.cCount = cCount;
	}
	public int getcMargin() {
		return cMargin;
	}

	public void setcMargin(int cMargin) {
		this.cMargin = cMargin;
	}
	public int sellingPrice(){//판매금액
		return cPrice * cCount;
	}
	public double surTax(){
		return Math.ceil(sellingPrice()/11);
	}
	public double provision(){//공급가액
		return sellingPrice()-surTax();
	}
	public double marginRate(){
		return Math.round(provision()*cMargin*0.01);
	}
	@Override
	public String toString() {
		return String
				.format("%s, %s, %s, %s, %s, %s, %s, %s, %s",
						cNum, cName, cPrice, cCount, cMargin, sellingPrice(),
						surTax(), provision(), marginRate());
	}
	@Override
	public int compareTo(Coffee o) {
		return cNum.hashCode()-o.cNum.hashCode();
	}
}
